package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.model.dispatch.DispatchCarItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 调度车辆操作类
 *
 * @author zhanglr
 * @date 2020-6-12 11:06
 */
public interface RecDispatchCarDao {
    /**
     * 根据接运信息id获取
     *
     * @param recId 接运信息主键
     * @return
     */
    @Select("select id,deleted,rec_id,rec_car_id,rec_car_no,dispatch_user_name,dispatch_user_id,dispatch_out_time,dispatch_back_time,odometer,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version" +
            " from rec_dispatch_car where rec_id = #{recId}  and deleted = 0  limit 1 ")
    DispatchCarItem selectRecDispatchCarByRecId(@Param("recId") Integer recId);

    /**
     * 根据recId删除调度信息
     *
     * @param recId          接运信息主键
     * @param modifiedUserId 修改用户外键
     * @return
     * @author GaoXiangLiang
     * @date 2020-06-16
     */
    @Update(" update rec_dispatch_car set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where rec_id = #{recId} and unmodified = 0 and deleted = 0 ")
    void deleteRecDispatchCarByRecId(@Param("recId") Integer recId, @Param("modifiedUserId") Integer modifiedUserId);
}
